package com.snake.springboot.custom.controller.base;

import com.snake.springboot.custom.api.model.base.CustRoleAccModel;
import com.snake.springboot.custom.api.response.base.CustRoleAccRsp;
import com.snake.springboot.custom.api.service.base.CustRoleAccService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.snake.common.result.ResponseResult;
import org.snake.common.result.ResponseResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>商户管理 - 角色子账号
 * 类{@code CustRoleAcc} </br>
 * 创建时间2025/2/11 9:38
 * @author yangxt
 * @see
 */
@Api(tags = "商户管理 - 角色子账号授权")
@RestController
@RequestMapping("/cust-role-acc")
public class CustRoleAccController {

    private CustRoleAccService roleAccService;
    @Autowired
    public CustRoleAccController(CustRoleAccService roleAccService) {
        this.roleAccService = roleAccService;
    }

    @ApiOperation("授权角色子账")
    @PostMapping("/authorize")
    public ResponseResult<Object> authorization(
            @ApiParam(name = "接口入参", value = "传入json格式", required = true)
            @RequestBody List<CustRoleAccModel> model) {
        roleAccService.authorization(model);
        return ResponseResultFactory.ucc("授权成功！");
    }
    @ApiOperation("取消操角色子账所有授权")
    @GetMapping("/cancel-authorization/{accountId}")
    public ResponseResult<Object> cancelAuthorization(
            @ApiParam(name = "accountId", value = "操作员ID", required = true)
            @PathVariable("accountId") String accountId) {
        roleAccService.cancelAuthorization(accountId);
        return ResponseResultFactory.ucc("操作成功!");
    }


    @ApiOperation("查询角色子账列表")
    @PostMapping("/list")
    public ResponseResult<List<CustRoleAccRsp>> queryList(
            @ApiParam(name = "查询条件", value = "传入json类型", required = true)
            @RequestBody CustRoleAccModel params) {
        List<CustRoleAccRsp> result = roleAccService.queryList(params);
        return ResponseResultFactory.ucc("查询成功！", result);
    }



}
